package tanshiru2.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tanshiru2.entity.Medicine;
import tanshiru2.mapper.MedicineMapper;

@Service
public class MedicineService extends ServiceImpl<MedicineMapper, Medicine> {

    public IPage<Medicine> getMedicinePageData(String medicineName,int pageSize,int curPage) {
        Page<Medicine> medicinePage = new Page<>(curPage, pageSize);
        QueryWrapper<Medicine> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(medicineName != null, "medicine_name", medicineName);
//        List<Medicine> records = this.page(medicinePage, queryWrapper).getRecords();
//        records.forEach(System.out::println);
        return this.page(medicinePage,queryWrapper);
    }
}
